import { createRouter, createWebHistory } from 'vue-router'
import HomeIndex from '@/views/index/HomeIndex.vue'
import UserLogin from '@/views/login/UserLogin.vue'
import UserRegister from '@/views/index/UserRegister.vue'
import VitalSigns from '@/views/index/VitalSigns.vue'
import BodyComposition from '@/views/index/BodyComposition.vue'
import BloodTests from '@/views/index/BloodTests.vue'
import DailyActivities from '@/views/index/DailyActivities.vue'
import HealthAssessments from '@/views/index/HealthAssessments.vue'
import TestPage from '@/views/index/TestPage.vue'

/**
 * @type {import('vue-router').RouteRecordRaw[]}
 */
const routes = [
  {
    path: '/',
    redirect: '/index/vital_signs',
  },
  {
    path: '/login',
    component: UserLogin,
  },
  {
    path: '/register',
    component: UserRegister,
  },
  {
    path: '/test',
    component: TestPage,
  },
  // 添加直接访问 vital_signs 等子页面的路由规则
  {
    path: '/vital_signs',
    redirect: '/index/vital_signs',
  },
  {
    path: '/body_composition',
    redirect: '/index/body_composition',
  },
  {
    path: '/blood_tests',
    redirect: '/index/blood_tests',
  },
  {
    path: '/daily_activities',
    redirect: '/index/daily_activities',
  },
  {
    path: '/health_assessments',
    redirect: '/index/health_assessments',
  },
  {
    path: '/index',
    component: HomeIndex,
    children: [
      {
        path: '',
        redirect: 'vital_signs',
      },
      {
        path: 'vital_signs',
        component: VitalSigns,
        meta: { title: '生命体征记录表' },
      },
      {
        path: 'body_composition',
        component: BodyComposition,
        meta: { title: '身体成分记录表' },
      },
      {
        path: 'blood_tests',
        component: BloodTests,
        meta: { title: '血液检测记录表' },
      },
      {
        path: 'daily_activities',
        component: DailyActivities,
        meta: { title: '日常活动记录表' },
      },
      {
        path: 'health_assessments',
        component: HealthAssessments,
        meta: { title: '健康评估记录表' },
      },
    ],
  },
]

/**
 * @type {import('vue-router').Router}
 */
const router = createRouter({
  history: createWebHistory('/'),
  routes,
})

export default router
